Skip to content

Keep a delivery going when the exception reporter raises for one stream - #743

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:keep_a_delivery_going_when_the_exception_reporter_raises_for_one_stream
Open

koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:keep_a_delivery_going_when_the_exception_reporter_raises_for_one_stream

Conversation

@koic

@koic koic commented Dec 3, 2026

Copy link
Copy Markdown
Member

Motivation and Context

A notification is written to one stream after another, and a write that fails on a stream is reported through the exception reporter before that stream is removed. A reporter that raised there ended the whole delivery: the failed stream stayed registered, the streams the delivery had not reached yet never received the notification, and the exception went to the code that emitted the change.

The report of a failed stream write now ignores a reporter that raises, on both paths that write to several streams: the subscriptions/listen streams and the streams of the sessions. The failed stream is removed as before, and the delivery continues with the next one. The second path is store_and_write, which also writes a message for a single session and the response of a request, so a failed write is handled the same way there: the stream is dropped and the caller is told that nothing was written. The other reports of the transport are unchanged.

How Has This Been Tested?

With two new tests in streamable_http_transport_test.rb, one per path: of two streams the first is broken, and the reporter raises. Both fail against the previous tree with the reporter's exception.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Test update (non-breaking change which adds or updates tests)
  • Refactoring (non-breaking change which makes things better)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • CI/build script update (update CI workflow or build scripts)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • I have added automated tests for my change
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Motivation and Context

A notification is written to one stream after another, and a write that fails on a stream is reported
through the exception reporter before that stream is removed. A reporter that raised there ended the whole delivery:
the failed stream stayed registered, the streams the delivery had not reached yet never received the notification,
and the exception went to the code that emitted the change.

The report of a failed stream write now ignores a reporter that raises, on both paths that write to several streams:
the `subscriptions/listen` streams and the streams of the sessions. The failed stream is removed as before,
and the delivery continues with the next one. The second path is `store_and_write`, which also writes a message
for a single session and the response of a request, so a failed write is handled the same way there:
the stream is dropped and the caller is told that nothing was written. The other reports of the transport are unchanged.

## How Has This Been Tested?

With two new tests in `streamable_http_transport_test.rb`, one per path: of two streams the first is broken,
and the reporter raises. Both fail against the previous tree with the reporter's exception.

## Breaking Changes

None.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant